/*************************************************************************
	> File Name: hzoj_244.cpp
	> Author: 
	> Mail: 
	> Created Time: Wed 14 Aug 2024 01:29:56 PM CST
 ************************************************************************/

#include<iostream>
#include <algorithm>
using namespace std;
#define MAX_N 500

struct Point
{
	int x, y;
} arr[MAX_N + 5];

int main() {
	int c ,n;
	cin >> c >> n;
	for(int i = 0; i < n; i++) {
		cin >> arr[i].x >> arr[i].y;
	}
	sort(arr, arr + n, [&](Point a, Point b) -> bool {
		if(a.x != b.x) return a.x < b.x;
		return a.y < b.y;
	});
	for(int i = 0; i < n; i++) {
		printf("(%d, %d)", arr[i].x, arr[i].y);
		printf("\n");
	}
	return 0;
}